package com.yochi.pictureseditor.tools;

import java.io.Serializable;

public class Color implements Serializable {
	
	private static final long serialVersionUID = 7099530242109206570L;
	
	private char r;
	private char g;
	private char b;
	
	public Color(char r, char g, char b) {
		this.r = r;
		this.g = g;
		this.b = b;
	}

	public char getR() {
		return r;
	}

	public char getG() {
		return g;
	}

	public char getB() {
		return b;
	}
	
	public int getHexaColor() {
    	return (int) Long.parseLong("FF"+getStringHexaColor(), 16);
	}
	
	public String getStringHexaColor() {
    	String sR;
    	String sG;
    	String sB;
		if(getR()<=15) sR = "0"+Integer.toHexString(getR());
		else sR = Integer.toHexString(getR());
		if(getG()<=15) sG = "0"+Integer.toHexString(getG());
		else sG = Integer.toHexString(getG());
		if(getB()<=15) sB = "0"+Integer.toHexString(getB());
		else sB = Integer.toHexString(getB());
		return sR+sG+sB;
	}

	@Override
	public String toString() {
		return "Color [r=" + r + ", g=" + g + ", b=" + b + "]";
	}
	
}
